package cn.yunhe.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by zs on 2017/12/18.
 */
@RequestMapping("/ch")
@Controller
public class CookieAndHeader {

    @RequestMapping("/header")
    public ModelAndView getCooieAndHeader(@RequestHeader(value = "User-Agent", required = false, defaultValue = "attr") String reqHeader,
    @CookieValue(value = "JSESSIONID" ,required = true,defaultValue = "mysessionid") String sessionId) {
        System.out.println("请求头===" + reqHeader);
        System.out.println("sessionid==="+sessionId);
        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        return mv;
    }

}
